package com.hongye.province.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.hongye.common.core.utils.bean.BeanUtils;
import com.hongye.common.domain.FangProvince;
import com.hongye.province.domain.vo.FangProvinceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hongye.province.mapper.FangProvinceMapper;

import com.hongye.province.service.IFangProvinceService;

/**
 * 省份列表Service业务层处理
 * 
 * @author hdd
 * @date 2025-01-09
 */
@Service
public class FangProvinceServiceImpl implements IFangProvinceService 
{
    @Autowired
    private FangProvinceMapper fangProvinceMapper;

    /**
     * 查询省份列表
     * 
     * @param id 省份列表主键
     * @return 省份列表
     */
    @Override
    public FangProvince selectFangProvinceById(Integer id)
    {
        return fangProvinceMapper.selectFangProvinceById(id);
    }

    /**
     * 查询省份列表列表
     * 
     * @param fangProvince 省份列表
     * @return 省份列表
     */
    @Override
    public List<FangProvinceVo> selectFangProvinceList(FangProvince fangProvince)
    {
        List<FangProvince> fangProvinces = fangProvinceMapper.selectFangProvinceList(fangProvince);
        ArrayList<FangProvinceVo> fangProvinceVos = new ArrayList<>();
        for (FangProvince province : fangProvinces) {
            FangProvinceVo fangProvinceVo = new FangProvinceVo();
            BeanUtils.copyBeanProp(fangProvinceVo,province);
            fangProvinceVos.add(fangProvinceVo);
        }
        return fangProvinceVos;
    }

    /**
     * 新增省份列表
     * 
     * @param fangProvince 省份列表
     * @return 结果
     */
    @Override
    public int insertFangProvince(FangProvince fangProvince)
    {
        return fangProvinceMapper.insertFangProvince(fangProvince);
    }

    /**
     * 修改省份列表
     * 
     * @param fangProvince 省份列表
     * @return 结果
     */
    @Override
    public int updateFangProvince(FangProvince fangProvince)
    {
        return fangProvinceMapper.updateFangProvince(fangProvince);
    }

    /**
     * 批量删除省份列表
     * 
     * @param ids 需要删除的省份列表主键
     * @return 结果
     */
    @Override
    public int deleteFangProvinceByIds(Integer[] ids)
    {
        return fangProvinceMapper.deleteFangProvinceByIds(ids);
    }

    /**
     * 删除省份列表信息
     * 
     * @param id 省份列表主键
     * @return 结果
     */
    @Override
    public int deleteFangProvinceById(Integer id)
    {
        return fangProvinceMapper.deleteFangProvinceById(id);
    }
}
